package com.iot.service.demo;

import io.netty.util.Timeout;
import io.netty.util.Timer;
import io.netty.util.TimerTask;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * @Author: hszhou
 * @Date: 2025/5/7 14:02
 * @Description: 任务类 hashwheeltimer执行的任务封装
 */
@Slf4j
@Data
public class CustomTask implements TimerTask {

    private final AppointmentRecord appointmentRecord;


    private Timeout timeout;

    public CustomTask(AppointmentRecord appointmentRecord) {
        this.appointmentRecord = appointmentRecord;
    }
    @Override
    public void run(Timeout timeout) throws Exception {

        Timer timer = timeout.timer();
        log.info("执行方法[{}]",appointmentRecord.getAppointmentId());
        this.timeout =  timer.newTimeout(this,3, TimeUnit.SECONDS);

    }
}
